
include_directories(
${SDK_DIR}
${SDK_DIR}/Vulkan-Headers/include
${SDK_DIR}/SPIRV-Tools/include
${CMAKE_CURRENT_SOURCE_DIR}/Glslang/OGLCompilersDLL
)

if (${PLATFORM_BITS} EQUAL 64)
   link_directories(
       "${SDK_DIR}/glslang/lib/x64/${CMAKE_BUILD_TYPE}"
	   "${SDK_DIR}/SPIRV-Tools/lib/x64/${CMAKE_BUILD_TYPE}"
   )
elseif (${PLATFORM_BITS} EQUAL 32)
   link_directories(
		"${SDK_DIR}/glslang/lib/x86/${CMAKE_BUILD_TYPE}" 
		"${SDK_DIR}/SPIRV-Tools/lib/x64/${CMAKE_BUILD_TYPE}"
    )
endif ()


add_definitions(
-D FG_CACHE_LINE=std::hardware_destructive_interference_size
-D FG_ENABLE_VULKAN_MEMORY_ALLOCATOR
-D FG_STD_STRINGVIEW
-D FG_STD_VARIANT
-D FG_STD_OPTIONAL
-D FG_ENABLE_GLSLANG
-D NV_EXTENSIONS
-D FG_STD_FILESYSTEM
-D ENABLE_OPT=1
-D ENABLE_HLSL
-D GLSLANG_OSINCLUDE_WIN32
-D AMD_EXTENSIONS

-D Meleon_DLL
)


#==================================================================================================
# project: Meleon
#==================================================================================================

set( SOURCES 

	"Vulkan/Loader/fn_vulkan_dev.h"
	"Vulkan/Loader/fn_vulkan_inst.h"
	"Vulkan/Loader/fn_vulkan_lib.h"
	"Vulkan/Loader/VulkanCheckError.cpp"
	"Vulkan/Loader/VulkanCheckError.h"
	"Vulkan/Loader/VulkanLoader.cpp"
	"Vulkan/Loader/VulkanLoader.h"

	"Vulkan/Memory/VMemoryManager.cpp"
	"Vulkan/Memory/VMemoryManager.h"
	"Vulkan/Memory/VMemoryManager_VMAllocator.cpp"
	"Vulkan/Memory/VMemoryObj.cpp"
	"Vulkan/Memory/VMemoryObj.h"
	"Vulkan/RayTracing/VLocalRTGeometry.cpp"
	"Vulkan/RayTracing/VLocalRTGeometry.h"
	"Vulkan/RayTracing/VLocalRTScene.cpp"
	"Vulkan/RayTracing/VLocalRTScene.h"
	"Vulkan/RayTracing/VRayTracingGeometry.cpp"
	"Vulkan/RayTracing/VRayTracingGeometry.h"
	"Vulkan/RayTracing/VRayTracingPipeline.cpp"
	"Vulkan/RayTracing/VRayTracingPipeline.h"
	"Vulkan/RayTracing/VRayTracingScene.cpp"
	"Vulkan/RayTracing/VRayTracingScene.h"
	"Vulkan/RayTracing/VRayTracingShaderTable.cpp"
	"Vulkan/RayTracing/VRayTracingShaderTable.h"

	"Public/BindingIndex.h"
	"Public/BufferDesc.h"
	"Public/BufferView.h"
	"Public/ColorScheme.h"
	"Public/CommandBuffer.h"
	"Public/CommandBufferPtr.h"
	"Public/Config.h"
	"Public/DrawCommandBuffer.h"
	"Public/DrawContext.h"
	"Public/EResourceState.h"
	"Public/FGEnums.h"
	"Public/FrameGraph.h"
	"Public/FrameGraphDrawTask.h"
	"Public/FrameGraphTask.h"
	"Public/IDs.h"
	"Public/ImageDesc.h"
	"Public/ImageLayer.h"
	"Public/ImageSwizzle.h"
	"Public/ImageView.h"
	"Public/MemoryDesc.h"
	"Public/MipmapLevel.h"
	"Public/MultiSamples.h"
	"Public/Pipeline.h"
	"Public/PipelineCompiler.h"
	"Public/PipelineResources.h"
	"Public/RayTracingEnums.h"
	"Public/RayTracingGeometryDesc.h"
	"Public/RayTracingSceneDesc.h"
	"Public/RenderPassDesc.h"
	"Public/RenderState.h"
	"Public/RenderStateEnums.h"
	"Public/ResourceEnums.h"
	"Public/SamplerDesc.h"
	"Public/SamplerEnums.h"
	"Public/ShaderEnums.h"
	"Public/Types.h"
	"Public/VertexDesc.h"
	"Public/VertexEnums.h"
	"Public/VertexInputState.h"
	"Public/VulkanTypes.h"

	"Vulkan/VCommon.h"

	"Vulkan/Instance/VDevice.cpp"
	"Vulkan/Instance/VDevice.h"
	"Vulkan/Instance/VFrameGraph.cpp"
	"Vulkan/Instance/VFrameGraph.h"
	"Vulkan/Instance/VResourceManager.cpp"
	"Vulkan/Instance/VResourceManager.h"

	"Vulkan/Debugger/VDebugger.cpp"
	"Vulkan/Debugger/VDebugger.h"
	"Vulkan/Debugger/VLocalDebugger.cpp"
	"Vulkan/Debugger/VLocalDebugger.h"
	"Vulkan/Debugger/VLocalDebugger2.cpp"

	"Vulkan/Image/VImage.cpp"
	"Vulkan/Image/VImage.h"
	"Vulkan/Image/VLocalImage.cpp"
	"Vulkan/Image/VLocalImage.h"
	"Vulkan/Image/VSampler.cpp"
	"Vulkan/Image/VSampler.h"

	"Vulkan/Swapchain/VSwapchain.cpp"
	"Vulkan/Swapchain/VSwapchain.h"

	"Shared/CreateFrameGraph.cpp"
	"Shared/EnumToString.h"
	"Shared/EnumUtils.h"
	"Shared/FrameGraph_Statistics.cpp"
	"Shared/HashCollisionCheck.h"
	"Shared/ImageDataRange.h"
	"Shared/ImageView.cpp"
	"Shared/ImageViewDesc.cpp"
	"Shared/ImageViewDesc.h"
	"Shared/LocalResourceID.h"
	"Shared/Pipeline.cpp"
	"Shared/PipelineResources.cpp"
	"Shared/PipelineResourcesHelper.h"
	"Shared/RenderState.cpp"
	"Shared/ResourceBase.h"
	"Shared/ResourceDataRange.h"
	"Shared/VertexInputState.cpp"

	"Vulkan/RenderPass/VFramebuffer.cpp"
	"Vulkan/RenderPass/VFramebuffer.h"
	"Vulkan/RenderPass/VLogicalRenderPass.cpp"
	"Vulkan/RenderPass/VLogicalRenderPass.h"
	"Vulkan/RenderPass/VRenderPass.cpp"
	"Vulkan/RenderPass/VRenderPass.h"

	"Vulkan/Utils/FGEnumCast.h"
	"Vulkan/Utils/VEnumCast.h"
	"Vulkan/Utils/VEnums.h"
	"Vulkan/Utils/VEnumToString.h"

	"Vulkan/Buffer/VBuffer.cpp"
	"Vulkan/Buffer/VBuffer.h"
	"Vulkan/Buffer/VLocalBuffer.cpp"
	"Vulkan/Buffer/VLocalBuffer.h"

	"Vulkan/Pipeline/VComputePipeline.cpp"
	"Vulkan/Pipeline/VComputePipeline.h"
	"Vulkan/Pipeline/VGraphicsPipeline.cpp"
	"Vulkan/Pipeline/VGraphicsPipeline.h"
	"Vulkan/Pipeline/VMeshPipeline.cpp"
	"Vulkan/Pipeline/VMeshPipeline.h"
	"Vulkan/Pipeline/VPipelineCache.cpp"
	"Vulkan/Pipeline/VPipelineCache.h"
	"Vulkan/Pipeline/VPipelineLayout.cpp"
	"Vulkan/Pipeline/VPipelineLayout.h"
	"Vulkan/CommandBuffer/VBarrierManager.h"
	"Vulkan/CommandBuffer/VCmdBatch.cpp"
	"Vulkan/CommandBuffer/VCmdBatch.h"
	"Vulkan/CommandBuffer/VCommandBuffer.cpp"
	"Vulkan/CommandBuffer/VCommandBuffer.h"
	"Vulkan/CommandBuffer/VCommandPool.cpp"
	"Vulkan/CommandBuffer/VCommandPool.h"
	"Vulkan/CommandBuffer/VDrawTask.h"
	"Vulkan/CommandBuffer/VSubmitted.cpp"
	"Vulkan/CommandBuffer/VSubmitted.h"
	"Vulkan/CommandBuffer/VTaskGraph.h"
	"Vulkan/CommandBuffer/VTaskGraph.hpp"
	"Vulkan/CommandBuffer/VTaskProcessor.cpp"
	"Vulkan/CommandBuffer/VTaskProcessor.h"
	"Vulkan/Descriptors/VDescriptorManager.cpp"
	"Vulkan/Descriptors/VDescriptorManager.h"
	"Vulkan/Descriptors/VDescriptorSetLayout.cpp"
	"Vulkan/Descriptors/VDescriptorSetLayout.h"
	"Vulkan/Descriptors/VPipelineResources.cpp"
	"Vulkan/Descriptors/VPipelineResources.h" 

	"Vulkan/Create/VulkanDevice.h"
	"Vulkan/Create/VulkanDevice.cpp"
	"Vulkan/Create/VulkanDeviceExt.h"
	"Vulkan/Create/VulkanDeviceExt.cpp"
	"Vulkan/Create/VulkanSwapchain.h"
	"Vulkan/Create/VulkanSwapchain.cpp"

	



	"PipelineCompiler/EShaderCompilationFlags.h"
	"PipelineCompiler/PrivateDefines.h"
	"PipelineCompiler/SpirvCompiler.cpp"
	"PipelineCompiler/SpirvCompiler.h"
	"PipelineCompiler/SpirvCompiler_Resources.cpp"
	"PipelineCompiler/VCachedDebuggableShaderData.h"
	"PipelineCompiler/VPipelineCompiler.cpp"
	"PipelineCompiler/VPipelineCompiler.h"

	"GLSLTrace/Common.h"
	"GLSLTrace/InsertDebugAsserts.cpp"
	"GLSLTrace/InsertInstructionCounter.cpp"
	"GLSLTrace/InsertTraceRecording.cpp"
	"GLSLTrace/ParseShaderTrace.cpp"
	"GLSLTrace/ShaderTrace.cpp"
	"GLSLTrace/ShaderTrace.h"

	"Defines.h"
	"Meleon.h"
	"Meleon.cpp"
)
add_library( "Meleon" SHARED ${SOURCES})
#add_library( "Meleon" STATIC ${SOURCES})

source_group( "Vulkan\\Memory" FILES "Vulkan/Memory/VMemoryManager.cpp" "Vulkan/Memory/VMemoryManager.h" "Vulkan/Memory/VMemoryManager_VMAllocator.cpp" "Vulkan/Memory/VMemoryObj.cpp" "Vulkan/Memory/VMemoryObj.h" )
source_group( "Vulkan\\RayTracing" FILES "Vulkan/RayTracing/VLocalRTGeometry.cpp" "Vulkan/RayTracing/VLocalRTGeometry.h" "Vulkan/RayTracing/VLocalRTScene.cpp" "Vulkan/RayTracing/VLocalRTScene.h" "Vulkan/RayTracing/VRayTracingGeometry.cpp" "Vulkan/RayTracing/VRayTracingGeometry.h" "Vulkan/RayTracing/VRayTracingPipeline.cpp" "Vulkan/RayTracing/VRayTracingPipeline.h" "Vulkan/RayTracing/VRayTracingScene.cpp" "Vulkan/RayTracing/VRayTracingScene.h" "Vulkan/RayTracing/VRayTracingShaderTable.cpp" "Vulkan/RayTracing/VRayTracingShaderTable.h" )
source_group( "Public" FILES "Public/BindingIndex.h" "Public/BufferDesc.h" "Public/BufferView.h" "Public/ColorScheme.h" "Public/CommandBuffer.h" "Public/CommandBufferPtr.h" "Public/Config.h" "Public/DrawCommandBuffer.h" "Public/DrawContext.h" "Public/EResourceState.h" "Public/FGEnums.h" "Public/Meleon.h" "Public/FrameGraphDrawTask.h" "Public/FrameGraphTask.h" "Public/IDs.h" "Public/ImageDesc.h" "Public/ImageLayer.h" "Public/ImageSwizzle.h" "Public/ImageView.h" "Public/MemoryDesc.h" "Public/MipmapLevel.h" "Public/MultiSamples.h" "Public/Pipeline.h" "Public/PipelineCompiler.h" "Public/PipelineResources.h" "Public/RayTracingEnums.h" "Public/RayTracingGeometryDesc.h" "Public/RayTracingSceneDesc.h" "Public/RenderPassDesc.h" "Public/RenderState.h" "Public/RenderStateEnums.h" "Public/ResourceEnums.h" "Public/SamplerDesc.h" "Public/SamplerEnums.h" "Public/ShaderEnums.h" "Public/Types.h" "Public/VertexDesc.h" "Public/VertexEnums.h" "Public/VertexInputState.h" "Public/VulkanTypes.h" )
source_group( "Vulkan" FILES "Vulkan/VCommon.h" )
source_group( "Vulkan\\Instance" FILES "Vulkan/Instance/VDevice.cpp" "Vulkan/Instance/VDevice.h" "Vulkan/Instance/VFrameGraph.cpp" "Vulkan/Instance/VFrameGraph.h" "Vulkan/Instance/VResourceManager.cpp" "Vulkan/Instance/VResourceManager.h" )
source_group( "Vulkan\\Debugger" FILES "Vulkan/Debugger/VDebugger.cpp" "Vulkan/Debugger/VDebugger.h" "Vulkan/Debugger/VLocalDebugger.cpp" "Vulkan/Debugger/VLocalDebugger.h" "Vulkan/Debugger/VLocalDebugger2.cpp" )
source_group( "Vulkan\\Image" FILES "Vulkan/Image/VImage.cpp" "Vulkan/Image/VImage.h" "Vulkan/Image/VLocalImage.cpp" "Vulkan/Image/VLocalImage.h" "Vulkan/Image/VSampler.cpp" "Vulkan/Image/VSampler.h" )
source_group( "Vulkan\\Swapchain" FILES "Vulkan/Swapchain/VSwapchain.cpp" "Vulkan/Swapchain/VSwapchain.h" )
source_group( "Shared" FILES "Shared/CreateFrameGraph.cpp" "Shared/EnumToString.h" "Shared/EnumUtils.h" "Shared/FrameGraph_Statistics.cpp" "Shared/HashCollisionCheck.h" "Shared/ImageDataRange.h" "Shared/ImageView.cpp" "Shared/ImageViewDesc.cpp" "Shared/ImageViewDesc.h" "Shared/LocalResourceID.h" "Shared/Pipeline.cpp" "Shared/PipelineResources.cpp" "Shared/PipelineResourcesHelper.h" "Shared/RenderState.cpp" "Shared/ResourceBase.h" "Shared/ResourceDataRange.h" "Shared/VertexInputState.cpp" )
source_group( "Vulkan\\RenderPass" FILES "Vulkan/RenderPass/VFramebuffer.cpp" "Vulkan/RenderPass/VFramebuffer.h" "Vulkan/RenderPass/VLogicalRenderPass.cpp" "Vulkan/RenderPass/VLogicalRenderPass.h" "Vulkan/RenderPass/VRenderPass.cpp" "Vulkan/RenderPass/VRenderPass.h" )
source_group( "Vulkan\\Utils" FILES "Vulkan/Utils/FGEnumCast.h" "Vulkan/Utils/VEnumCast.h" "Vulkan/Utils/VEnums.h" "Vulkan/Utils/VEnumToString.h" )
source_group( "Vulkan\\Buffer" FILES "Vulkan/Buffer/VBuffer.cpp" "Vulkan/Buffer/VBuffer.h" "Vulkan/Buffer/VLocalBuffer.cpp" "Vulkan/Buffer/VLocalBuffer.h" )
source_group( "cmake" FILES "../cmake/angelscript_CMakeLists.txt" "../cmake/compilers.cmake" "../cmake/compiler_tests.cmake" "../cmake/download_angelscript.cmake" "../cmake/download_assimp.cmake" "../cmake/download_devil.cmake" "../cmake/download_freeimage.cmake" "../cmake/download_glfw.cmake" "../cmake/download_glm.cmake" "../cmake/download_glslang.cmake" "../cmake/download_imgui.cmake" "../cmake/download_lodepng.cmake" "../cmake/download_mem.cmake" "../cmake/download_sdl2.cmake" "../cmake/download_sfml.cmake" "../cmake/download_stdoptional.cmake" "../cmake/download_stdvariant.cmake" "../cmake/download_vk.cmake" "../cmake/download_vma.cmake" "../cmake/graphviz.cmake" "../cmake/imgui_CMakeLists.txt" "../cmake/lodepng_CMakeLists.txt" )
source_group( "Vulkan\\Pipeline" FILES "Vulkan/Pipeline/VComputePipeline.cpp" "Vulkan/Pipeline/VComputePipeline.h" "Vulkan/Pipeline/VGraphicsPipeline.cpp" "Vulkan/Pipeline/VGraphicsPipeline.h" "Vulkan/Pipeline/VMeshPipeline.cpp" "Vulkan/Pipeline/VMeshPipeline.h" "Vulkan/Pipeline/VPipelineCache.cpp" "Vulkan/Pipeline/VPipelineCache.h" "Vulkan/Pipeline/VPipelineLayout.cpp" "Vulkan/Pipeline/VPipelineLayout.h" )
source_group( "" FILES "CMakeLists.txt"  "Defines.h" "Meleon.h" "Meleon.cpp")
source_group( "Vulkan\\CommandBuffer" FILES "Vulkan/CommandBuffer/VBarrierManager.h" "Vulkan/CommandBuffer/VCmdBatch.cpp" "Vulkan/CommandBuffer/VCmdBatch.h" "Vulkan/CommandBuffer/VCommandBuffer.cpp" "Vulkan/CommandBuffer/VCommandBuffer.h" "Vulkan/CommandBuffer/VCommandPool.cpp" "Vulkan/CommandBuffer/VCommandPool.h" "Vulkan/CommandBuffer/VDrawTask.h" "Vulkan/CommandBuffer/VSubmitted.cpp" "Vulkan/CommandBuffer/VSubmitted.h" "Vulkan/CommandBuffer/VTaskGraph.h" "Vulkan/CommandBuffer/VTaskGraph.hpp" "Vulkan/CommandBuffer/VTaskProcessor.cpp" "Vulkan/CommandBuffer/VTaskProcessor.h" )
source_group( "Vulkan\\Descriptors" FILES "Vulkan/Descriptors/VDescriptorManager.cpp" "Vulkan/Descriptors/VDescriptorManager.h" "Vulkan/Descriptors/VDescriptorSetLayout.cpp" "Vulkan/Descriptors/VDescriptorSetLayout.h" "Vulkan/Descriptors/VPipelineResources.cpp" "Vulkan/Descriptors/VPipelineResources.h" )
source_group("Vulkan\\Create" FILES 
	"Vulkan/Create/VulkanDevice.h"
	"Vulkan/Create/VulkanDevice.cpp"
	"Vulkan/Create/VulkanDeviceExt.h"
	"Vulkan/Create/VulkanDeviceExt.cpp"
	"Vulkan/Create/VulkanSwapchain.h"
	"Vulkan/Create/VulkanSwapchain.cpp"
)
source_group("Vulkan\\Loader" FILES 	
	"Vulkan/Loader/fn_vulkan_dev.h"
	"Vulkan/Loader/fn_vulkan_inst.h"
	"Vulkan/Loader/fn_vulkan_lib.h"
	"Vulkan/Loader/VulkanCheckError.cpp"
	"Vulkan/Loader/VulkanCheckError.h"
	"Vulkan/Loader/VulkanLoader.cpp"
	"Vulkan/Loader/VulkanLoader.h"
)


source_group("PipelineCompiler" FILES
	"PipelineCompiler/EShaderCompilationFlags.h"
	"PipelineCompiler/PrivateDefines.h"
	"PipelineCompiler/SpirvCompiler.cpp"
	"PipelineCompiler/SpirvCompiler.h"
	"PipelineCompiler/SpirvCompiler_Resources.cpp"
	"PipelineCompiler/VCachedDebuggableShaderData.h"
	"PipelineCompiler/VPipelineCompiler.cpp"
	"PipelineCompiler/VPipelineCompiler.h"
)

source_group("GLSLTrace" FILES
	"GLSLTrace/Common.h"
	"GLSLTrace/InsertDebugAsserts.cpp"
	"GLSLTrace/InsertInstructionCounter.cpp"
	"GLSLTrace/InsertTraceRecording.cpp"
	"GLSLTrace/ParseShaderTrace.cpp"
	"GLSLTrace/ShaderTrace.cpp"
	"GLSLTrace/ShaderTrace.h"
)

target_include_directories( "Meleon" PUBLIC ".." )
target_include_directories( "Meleon" PUBLIC "${FG_EXTERNALS_PATH}" )
target_include_directories( "Meleon" PRIVATE "Vulkan/Utils" )
target_include_directories( "Meleon" PRIVATE "Vulkan/RenderPass" )
target_include_directories( "Meleon" PRIVATE "Vulkan/Pipeline" )
target_include_directories( "Meleon" PRIVATE "Vulkan/RayTracing" )
target_include_directories( "Meleon" PRIVATE "" )
target_include_directories( "Meleon" PRIVATE "Vulkan/CommandBuffer" )
target_include_directories( "Meleon" PRIVATE "Vulkan/Swapchain" )
target_include_directories( "Meleon" PRIVATE "Vulkan/Instance" )
target_include_directories( "Meleon" PRIVATE "Vulkan/Image" )
target_include_directories( "Meleon" PRIVATE "Vulkan/Memory" )
target_include_directories( "Meleon" PRIVATE "Vulkan/Debugger" )
target_include_directories( "Meleon" PRIVATE "Vulkan" )
target_include_directories( "Meleon" PRIVATE "Vulkan/Buffer" )
target_include_directories( "Meleon" PRIVATE "Vulkan/Descriptors" )


if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
	target_link_libraries("Meleon" 
		"GSStl_d" 

		"glslangd" 
		"SPVRemapperd" 
		"SPIRVd" 
		"HLSLd"
		"OGLCompilerd"
		"OSDependentd"

		"SPIRV-Tools" 
		"SPIRV-Tools-opt"
	)
elseif(${CMAKE_BUILD_TYPE} STREQUAL "Release")
	target_link_libraries("Meleon" 
		"GSStl" 

		"glslang" 
		"SPVRemapper" 
		"SPIRV" 
		"HLSL"
		"OGLCompiler"
		"OSDependent"

		"SPIRV-Tools" 
		"SPIRV-Tools-opt"
	)
endif()

# compiler
target_compile_definitions( "Meleon" PRIVATE $<$<CONFIG:Debug>: ${PROJECTS_SHARED_DEFINES_DEBUG}> )
target_compile_definitions( "Meleon" PRIVATE $<$<CONFIG:Profile>: ${PROJECTS_SHARED_DEFINES_PROFILE}> )
target_compile_options( "Meleon" PRIVATE $<$<CONFIG:Release>: ${PROJECTS_SHARED_CXX_FLAGS_RELEASE}> )
target_compile_options( "Meleon" PRIVATE $<$<CONFIG:Profile>: ${PROJECTS_SHARED_CXX_FLAGS_PROFILE}> )
target_compile_options( "Meleon" PRIVATE $<$<CONFIG:Debug>: ${PROJECTS_SHARED_CXX_FLAGS_DEBUG}> )
target_compile_definitions( "Meleon" PRIVATE $<$<CONFIG:Release>: ${PROJECTS_SHARED_DEFINES_RELEASE}> )

if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
    set_property(TARGET "Meleon"  PROPERTY DEBUG_POSTFIX _d)
endif()